import { defineStore } from 'pinia'
import { getShareList } from '@/service/api'

export default defineStore('share', {
  state() {
    return {
      list: []
    }
  },
  getters: {
    getFormatList(state) {
      return state.list.map((item: any) => {
        item.file.type = item.file.ext === '' ? 'dir' : item.file.ext.substring(0, item.file.ext.lastIndexOf('/'))
        return item
      })
    }
  },
  actions: {
    async getAxiosList() {
      const res = await getShareList()
      this.list = res.data.data.rows
    }
  }
})